﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Douban.Modules.Broadcast.ViewModels;

namespace Douban.Modules.Broadcast.Views
{
    /// <summary>
    /// Interaction logic for BroadcastItemView.xaml
    /// </summary>
    public partial class BroadcastItemView : UserControl
    {
        private const int MaxLength = 140;

        public BroadcastItemView()
        {
            InitializeComponent();
        }

        public BroadcastItemViewModel Context { get; set; }

        public void ExpandComments()
        {
            if (this.CommentPanel.Visibility == Visibility.Visible)
                this.CommentPanel.Visibility = Visibility.Collapsed;
            else
                this.CommentPanel.Visibility = Visibility.Visible;
        }

        private void UserControl_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != null)
            {
                Context = e.NewValue as BroadcastItemViewModel;
                Context.View = this;
            }
        }
    }
}
